package com.hxzy.research.controller.front;

import com.hxzy.research.form.CompositeForm;
import com.hxzy.research.pojo.TblCompResearch;
import com.hxzy.research.service.pageandmanager.AddFrontComposite;
import com.hxzy.research.util.ListSumUtil;
import com.hxzy.research.vo.ResultVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping(value = "/front")
public class AddFrontCompositeController {
    @Autowired private AddFrontComposite addFrontComposite;
    @RequestMapping("/addCompResearch.go")
    public @ResponseBody
    ResultVo addCompositeResearch(CompositeForm compositeForm, HttpSession session)throws Exception{
        Integer branchId=(Integer) session.getAttribute("branchId");
        TblCompResearch tblCompResearch=new TblCompResearch();
        tblCompResearch.setBranchId(branchId);
        tblCompResearch.setClassId(compositeForm.getClassId());
        tblCompResearch.setZyyb(ListSumUtil.getSum(compositeForm.getZyyb()));
        tblCompResearch.setJxtd(ListSumUtil.getSum(compositeForm.getJxtd()));
        tblCompResearch.setJxxg(ListSumUtil.getSum(compositeForm.getJxxg()));
        tblCompResearch.setJxhj(ListSumUtil.getSum(compositeForm.getJxhj()));
        tblCompResearch.setGlfw(ListSumUtil.getSum(compositeForm.getGlfw()));
        tblCompResearch.setXgjy(ListSumUtil.getSum(compositeForm.getXgjy()));
        tblCompResearch.setGsjy(compositeForm.getGsjy());
        tblCompResearch.setLsjy(compositeForm.getLsjy());
        tblCompResearch.setTjDate(new Date());
        addFrontComposite.AddCompResearch(tblCompResearch);
        ResultVo resultVo=new ResultVo("200","提交成功");
        return resultVo;
    }
}
